#!/bin/sh
set -exuo pipefail
export COSA_SKIP_OVERLAY=1

if [ "$(uname -m)" == "x86_64" ] ; then
	IMAGE="10.30.38.116/utccp-amd64/dependence-uccps-os" ;
elif [ "$(uname -m)" == "aarch64" ] ; then
	IMAGE="10.30.38.116/utccp-arm64/dependence-uccps-os" ;
elif [ "$(uname -m)" == "loongarch64" ] ; then
	IMAGE="10.30.38.116/utccp-loong64/dependence-uccps-os" ;
fi

#sed -i '$a [[registry]]\n  prefix = ""\n  location = "10.30.38.116"\n  insecure = true' /etc/containers/registries.conf
#cp /src/registries.conf /etc/containers/registries.conf

#alias buildah="buildah --tls-verify=false"
# Copy registry csr file
mkdir -p /root/.docker
cp /src/config.json  /root/.docker

cosa init http://10.30.38.104:8099/uswift-config --branch uccps-1.2 --force

# Create repo for OKD RPMs
#pushd /srv/okd-repo
#  createrepo_c .
#popd

# build ostree commit
cosa fetch
cosa build ostree
#cosa  buildfetch --url http://10.10.15.12:8090 --artifact ostree
# Create repo for OS Extensions
#mkdir -p /overlay/extensions
#pushd /overlay/extensions
#  createrepo_c .
#popd

echo "Building container"
cosa upload-oscontainer --name $IMAGE 
